<?php
class Morderoutdetail extends CI_Model {
    protected $_table="";
    public function __construct() {
        parent::__construct();
        $this->_table="order_out_detail";
    }
    
    public function listAll($oo_id) {
        $query=$this->db->query("SELECT o . * , p.pro_title
                                FROM order_out_detail AS o
                                INNER JOIN products AS p ON p.pro_id = o.pro_id
                                where o.oo_id = $oo_id");
        if($query->num_rows()>0) return $query->result_array(); else return false;
    }
    
    public function countAll() {
        return $this->db->count_all($this->_table);
    }
    
    public function getById($id) {
        $query=$this->db->query("SELECT o . * , p.pro_title
                                FROM order_out_detail AS o
                                INNER JOIN products AS p ON p.pro_id = o.pro_id
                                where o.ood_id = $id");
        if($query->num_rows()>0) return $query->row_array(); else return false;
    }
    
    public function update($data, $id) {
        $this->db->where("ood_id", $id);
        $this->db->update($this->_table, $data);
    }
    
    public function del($id) {
        $this->db->where("ood_id", $id);
        $this->db->delete($this->_table);
    }
}
?>
